home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / dev / c / appsource.lha / APlusPlus / GNUC++ / APPLibrary / gnutoscmsg.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1994-08-02  |  3.4 KB  |  90 lines

  1. /* AREXX script for converting GNU compiler error messages
  2.  * into AREXX commands for the SAS/C message browser
  3.  * Copyright (C)1994 by Armin Vogt
  4.  *
  5.  * $Id: gnutoscmsg.rexx,v 1.5 1994/08/02 18:59:13 Armin_Vogt Exp Armin_Vogt $
  6.  *
  7.  * email: armin@uni-paderborn.de
  8.  *
  9.  *
  10.  * Start this script with 'Rx <name_of_this_file>' in the background.
  11.  * It will then start the SCMSG command and wait for input
  12.  * from the 'pipe:gnu_errors'.
  13.  * Now start your compiler and redirect its output to 'pipe:gnu_errors'.
  14.  * Shut down the script with writing a single line "quit" to 'pipe:gnu_errors'.
  15.  * This script can handle both Amiga and Unix path specifications.
  16.  */
  17.  
  18.    
  19.    if SHOW(P,"SC_SCMSG")~=0 then
  20.       ADDRESS 'SC_SCMSG' "clear"    /* cause SCMSG to clear all messages */
  21.       
  22.    inputfile = "pipe:gnu_errors"
  23.    if OPEN("errors",inputfile) then
  24.    do
  25.       say "pipe opened."
  26.       input = ""
  27.       firstmsg = 0
  28.       
  29.       do until input="quit"
  30.          
  31.          input = READLN("errors")
  32.          if input ~= "" & input ~= "quit" then 
  33.          do
  34.             /*say ">" input*/
  35.             
  36.             /* Check wether the SCMSG port is already there. 
  37.                If he's not start scmsg. */
  38.             if SHOW(P,"SC_SCMSG")=0 then
  39.             do
  40.                ADDRESS COMMAND "Run sc:c/scmsg"
  41.                /* give the previous command time to load scmsg */
  42.                ADDRESS COMMAND "Wait SEC=2"
  43.             end   
  44.             /* Divide line into file+linenumber and error text */
  45.             input = STRIP(input)    /* remove leading and trailing spaces */
  46.             parse VALUE input WITH  Line ": " Text
  47.             
  48.             if Text ~= "" then /* if no ': ' found -> no gcc output at all */
  49.             do
  50.                lp = LASTPOS(":",Line)  /* Find ":" in front of the line number */
  51.                Number = RIGHT(Line,LENGTH(Line)-lp)
  52.                if DATATYPE(Number)=NUM then 
  53.                do
  54.                   File = LEFT(Line,lp-1)
  55.                   Line = Number
  56.                   Class = "Error"
  57.                end
  58.                else 
  59.                do
  60.                   File = Line;
  61.                   Line = 0       /* no error number present -> info line*/
  62.                   Class = "Info"
  63.                end
  64.  
  65.                if FIND(Text,"warning:")~=0 then 
  66.                   Class = "Warning"
  67.  
  68.                if LEFT(File,1)="/" then   /* transform unix path into Amiga path */
  69.                do 
  70.                   File = DELSTR(File,1,1);   /* delete leading '/' */
  71.                   File = OVERLAY(":",File,POS("/",File),1); /* overwrite second '/' with ':' */
  72.                end
  73.                say """"File""" """File""" """Line"""  """Class""" """Text""""
  74.             
  75.                if firstmsg=1 then   /* on start of a new file clear all messages.. */
  76.                do                   /* to this file present in SCMSG. */
  77.                   ADDRESS 'SC_SCMSG' "newbld """File""
  78.                   firstmsg = 0;
  79.                end                  
  80.                /* send the message to SCMSG with the 'newmsg' command */
  81.                ADDRESS 'SC_SCMSG' "newmsg """File""" """File""" "Line" 0 """" 0 "Class" 0 "Text""
  82.             end
  83.          end   /* if input ~= "" & input ~= "quit" then */
  84.          else firstmsg = 1            /* indicate first message on new compilatin unit */
  85.       end   /* do until input="quit" */
  86.  
  87.       CLOSE("errors")
  88.    end
  89.    else say inputfile " could not be opened!"
  90.